package com.zy.xuanwo.zyc.portal.parser.imp;



import com.zy.xuanwo.zyc.portal.bean.Product;
import com.zy.xuanwo.zyc.portal.parser.BaseParser;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * remarks:
 * Created by ChowYvlChen on 2016/7/6  09:56
 */
public class ProductParser extends BaseParser<Product> {
    private Product mProduct = null;

    @Override
    public Product parserJSON(String jsonStr) throws JSONException {
        if (super.ParseResultPoly(jsonStr) == null) {
            mProduct = new Product();
            JSONObject mJSONObject = new JSONObject(jsonStr);
            if (mJSONObject.has("product_id")) {
                mProduct.setProduct_id(mJSONObject.getString("product_id"));
            }
            if (mJSONObject.has("secret_key")) {
                mProduct.setSecret_key(mJSONObject.getString("secret_key"));
            }
        }
        return mProduct;
    }
}
